﻿using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Xms.Abp.Application.Dtos;
using Xms.Abp.AspNetCore.Mvc;

namespace SettingsManagement;

[RemoteService(Name = SettingsManagementRemoteServiceConsts.RemoteServiceName)]
[Area(SettingsManagementRemoteServiceConsts.ModuleName)]
[Route("api/management/settings")]
public class SettingsController : XmsController<ISettingsManagementAppService>, ISettingsManagementAppService
{
    [HttpGet]
    [Route("{providerName}/{providerKey}/{typeName}")]
    public async Task<SettingsInfoResult> GetAsync(string providerName, string providerKey, string typeName)
        => await CurrentService.GetAsync(providerName, providerKey, typeName);

    [HttpGet]
    [Route("{providerName}/page")]
    public async Task<PagedResultDto<SettingsInfoListResult>> GetListAsync(string providerName, PagedSortedAndFilterParameter parameter)
        => await CurrentService.GetListAsync(providerName, parameter);

    [HttpPut]
    [Route("{providerName}/reset")]
    public async Task ResetAsync(string providerName, SettingsResetParameter parameter)
        => await CurrentService.ResetAsync(providerName, parameter);

    [HttpPut]
    [Route("{providerName}/update")]
    public async Task SetAsync(string providerName, SettingsUpdateParameter parameter)
        => await CurrentService.SetAsync(providerName, parameter);
}
